#include "FriendInfoWindow.h"
#include "ui_FriendInfoWindow.h"

FriendInfoWindow::FriendInfoWindow(struct st_friendData data,QWidget *parent) :
    QWidget(parent),
    ui(new Ui::FriendInfoWindow)
{
    ui->setupUi(this);
    //qDebug()<<"FriendWindow 构造";

    // qss渲染
    setQssStyle(QString("../style/FriendInfoWindow.qss"),this);

    // 只保留关闭和最小化按钮
    this->setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint);
    this->setWindowTitle("好友个人资料");

    m_fdata = data;
    QString head_url = QString("%1.png").arg(m_fdata.dd_num);
    QString srvpath = QString("%1/%2").arg(PATH_IMG).arg(head_url);
    ui->lab_head->setPixmap(PixmapToRoundOpenCV(downLoadFromUrl(srvpath)));

    ui->lab_uid->setText("UID："+QString::number(m_fdata.dd_num));
    ui->lab_nick->setText("昵称："+m_fdata.nick);
    ui->lab_nick_2->setText(m_fdata.nick);
    ui->lab_sex->setText("性别："+m_fdata.sex);
    ui->lab_phone->setText("电话："+m_fdata.phone);
    ui->lab_email->setText("邮箱："+m_fdata.email);
    ui->lab_home->setText("家乡："+m_fdata.city);
    ui->lab_birthday->setText("生日："+m_fdata.birthday);
    ui->lab_gxqm->setText(m_fdata.gxqm);
    ui->lab_gxqm->setWordWrap(true);

    //关闭释放内存 (若隐藏则什么操作也不做,效果和窗口关闭事件里写delete this一样)
    // setAttribute(Qt::WA_DeleteOnClose);
}

FriendInfoWindow::~FriendInfoWindow()
{
    //qDebug()<<"FriendWindow 析构";
    delete ui;
}

//void FriendInfoWindow::closeEvent(QCloseEvent *event)
//{
//    delete this;
//}

void FriendInfoWindow::on_btn_send_clicked()
{
    this->close();
    emit sig_infoWindowShow(m_fdata.dd_num);
}

